home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
TEMP
/
GNU
/
bison
/
RpcalcGeo
< prev
next >
Wrap
Text File
|
1995-06-28
|
1KB
|
32 lines
Rpcalc Gen
Previous: <Rpcalc Error=>RpcalcErrp> * Next: <Rpcalc Compile=>RpcalcComq> * Up: <RPN Calc=>RPNCalc>
#Wrap on
{fH4}Running Bison to Make the Parser{f}
Before running Bison to produce a parser, we need to decide how to arrange
all the source code in one or more source files. For such a simple example,
the easiest thing is to put everything in one file. The definitions of
{fCode}yylex{f}, {fCode}yyerror{f} and {fCode}main{f} go at the end, in the
``additional C code'' section of the file (\*Note <Grammar Layout=>GrammarLay>: The Overall Layout of a Bison Grammar).
For a large project, you would probably have several source files, and use
{fCode}make{f} to arrange to recompile them.
With all the source in a single file, you use the following command to
convert it into a parser file:
#Wrap off
#fCode
bison {fStrong}file\_name{f}.y
#f
#Wrap on
In this example the file was called {fCite}rpcalc.y{f} (for ``Reverse Polish
CALCulator''). Bison produces a file named {fCite}{fStrong}file\_name{f}.tab.c{f},
removing the {fEmphasis}.y{f} from the original file name. The file output by
Bison contains the source code for {fCode}yyparse{f}. The additional
functions in the input file ({fCode}yylex{f}, {fCode}yyerror{f} and {fCode}main{f})
are copied verbatim to the output.